package com.nstar.orderexpress.commands
{
	import com.adobe.cairngorm.control.CairngormEvent;
	import mx.rpc.IResponder;
	import com.adobe.cairngorm.commands.Command;
	import com.nstar.orderexpress.model.Model;
	import com.nstar.base.util.Logger;
	import com.nstar.orderexpress.business.OrderExpressDelegate;
	import com.nstar.components.ErrorView;
	import mx.utils.ObjectUtil;
	import com.nstar.orderexpress.control.PingEvent;
	import mx.controls.Alert;

	public class PingCommand implements Command, IResponder
	{
		private var model:Model = Model.getInstance();
		private var logger:Logger = Logger.getInstance();
		
		public function execute(event:CairngormEvent):void
		{
			//TODO: implement function
			//TODO: implement function
			var delegate:OrderExpressDelegate = new OrderExpressDelegate(this);//由代理来调用异步处理方法
			//强制转换成自定义的CairngormEvent事件，以获得自定义事件的属性
			var pingEvent:PingEvent = PingEvent(event);
			//调用代理中的方法
			delegate.pingSQL(pingEvent.sqltext);
		}
		
		public function result(data:Object):void
		{
			//TODO: implement function
			var s:String = "ping result:\n";
			s += "-------------------------------------\n";
			s += ObjectUtil.toString(data);
			Alert.show(s,"Ping的返回结果");
		}
		
		public function fault(info:Object):void
		{
			//TODO: implement function
			ErrorView.showErrorView(info);
		}
		
	}
}